<script setup>
import {
    Management,
    UserFilled
} from '@element-plus/icons-vue'
import {useUserStore} from '@/stores/user'
import {useRouter} from 'vue-router';
const userStore = useUserStore()
const router = useRouter()
const confirm = () =>{
  userStore.clearUserInfo()
  router.push('/login')
}
</script>

<template>
    <el-container class="layout-container">
        <!-- 左侧菜单 -->
        <el-aside width="200px">
            <div class="el-aside__logo"></div>
            <el-menu active-text-color="#ffd04b" background-color="#232323" text-color="#fff" router>
                <el-menu-item index="/admin/category">
                    <el-icon>
                        <Management />
                    </el-icon>
                    <span>主分类</span>
                </el-menu-item>
                <el-menu-item index="/admin/subcategory">
                    <el-icon>
                        <Management />
                    </el-icon>
                    <span>商品分类</span>
                </el-menu-item>
                <el-menu-item index="/admin/banner">
                    <el-icon>
                        <Management />
                    </el-icon>
                    <span>轮播图管理</span>
                </el-menu-item>
                <el-menu-item index="/admin/user">
                    <el-icon>
                        <UserFilled />
                    </el-icon>
                    <span>用户管理</span>
                </el-menu-item>
            </el-menu>
        </el-aside>
        <!-- 右侧主区域 -->
        <el-container>
            <!-- 头部区域 -->
            <el-header>
                <i class="iconfont icon-tuichu">
                    <el-popconfirm @confirm="confirm" title="确认退出吗?" confirm-button-text="确认" cancel-button-text="取消">
                        <template #reference>
                            <a href="javascript:;">退出登录</a>
                        </template>
                    </el-popconfirm>
                </i>
            </el-header>
            <!-- 中间区域 -->
            <el-main>
                <router-view />
            </el-main>
            <!-- 底部区域 -->
            <el-footer> ©懒</el-footer>
        </el-container>
    </el-container>
</template>

<style lang="scss" scoped>
.layout-container {
    height: 100vh;

    .el-aside {
        background-color: #232323;

        &__logo {
            height: 120px;
            background: url('@/assets/images/logo_admin.png') no-repeat center / 120px auto;
        }

        .el-menu {
            border-right: none;
        }
    }

    .el-header {
        background-color: #fff;
        display: flex;
        align-items: center;
        justify-content: space-between;

        .el-dropdown__box {
            display: flex;
            align-items: center;

            .el-icon {
                color: #999;
                margin-left: 10px;
            }

            &:active,
            &:focus {
                outline: none;
            }
        }
    }

    .el-footer {
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 14px;
        color: #666;
    }
}
</style>